tests/testthat/profiling for rowmean of predicted ys.R

library(microbenchmark)

test <- as.data.frame(matrix(runif(1e8), ncol = 500))

# Alternative 1
y_predicted <- apply(X = test, MARGIN = 1, FUN = mean)

# Alternative 2
y_predicted <- (rowmeanC(as.matrix(test)))


mbm <- microbenchmark::microbenchmark(
  # Alternative 1
  y_predicted1 <- apply(X = test, MARGIN = 1, FUN = mean),

  # Alternative 2
  y_predicted2 <- (rowmeanC(as.matrix(test))),
  times = 5

)
mbm

all(apply(X = y_bootstrap, MARGIN = 1, FUN = mean) == as.data.frame(rowmeanC(as.matrix(y_bootstrap))))

# check whether both functions yield the same result
all(round(y_predicted1,10) == round(y_predicted2,10))
nikosbosse/SAE documentation built on May 12, 2019, 4:37 a.m.